package com.atguigu.IO;

import com.atguigu.practice.UdpEchoServer;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpTranslateServer extends UdpEchoServer {
    //翻译本质上根据key找到value
    private Map<String,String> dict=new HashMap<>();
    public UdpTranslateServer(int port) throws SocketException {
        super(port);
        dict.put("cat","小猫");
        dict.put("dog","小狗");
        dict.put("kunkun","鸡哥");
        dict.put("duck","鸭");
    }

    public static void main(String[] args) throws IOException {
        UdpTranslateServer server=new UdpTranslateServer(9090);
        server.start();
    }

    @Override
    public String process(String request){
        return dict.getOrDefault(request,"词在词典中未找到");
    }
}
